package com.jlnk.androidfmc.presenter;

import androidx.fragment.app.Fragment;

import com.jlnk.androidfmc.fragment.fragments.homefragment.FruitsVegetablesFragment;
import com.jlnk.androidfmc.fragment.fragments.homefragment.GrainsOilFragment;
import com.jlnk.androidfmc.fragment.fragments.homefragment.RecommendFragment;
import com.jlnk.androidfmc.view.BuyerHomeView;

public class BuyerHomePresenterImpl implements BuyerHomePresenter {
    private BuyerHomeView view;

    public BuyerHomePresenterImpl(BuyerHomeView view) {
        this.view = view;
    }

    @Override
    public void onCategoryClicked(int categoryIndex) {
        Fragment fragment = getFragmentForCategory(categoryIndex);
        view.loadFragment(fragment);
    }

    private Fragment getFragmentForCategory(int categoryIndex) {
        // 根据分类索引返回不同的Fragment
        switch (categoryIndex) {
            case 0: return new RecommendFragment();
            case 1: return new FruitsVegetablesFragment();
            case 2: return new GrainsOilFragment();
            // 可以根据需要添加更多case
            default: throw new IllegalArgumentException("Unknown category index");
        }
    }
}